All Questions
Tagged with inheritancec++
65 questions
0votes
1answer
85views
Implementing safe custom exception [closed]
I was trying to come up with some design to subclass built-in exceptions. For simplest case I used something like this: ...
5votes
2answers
285views
ostream that counts and discards the characters written to it
The code below implements a class, CountingOStream, whose job is to count the number of characters written to it while also discarding those characters and ...
2votes
1answer
516views
Statically allocated buffer using templates
I want to have some classes that would contain arrays of different sizes. I want this to be statically allocated because it is intended for an embedded system. The only good solution I can think of is ...
0votes
1answer
483views
Class that counts its instances
I'd love some feedback on the C++ base class shown below. It's basically a toy problem for a fake video game where the monsters that you have to avoid will all be sub-classed from the class shown ...
0votes
1answer
222views
C++20 Wrapper class for an unsigned integer type and a templated derived class that codes modular arithmetic type
The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
0votes
1answer
43views
Deduplicate << operator implementation on inheritance
I have the following working code: person.h ...
2votes
1answer
65views
Colour-model classes using CRTP
I want to implement color space logic. So I started with creating some structs: ...
4votes
1answer
2kviews
multiple inheritance in c++ to implement different interfaces
I am working on a finite element (FE) code and want to provide multiple material models (20+). In FE applications, the computational domain is subdivided into a set of geometrically simple elements, e....
4votes
1answer
3kviews
OpenGL Mesh Class
I've written a simple mesh class. The purpose of it is to build a mesh, draw it to the screen, and provide some means by which the mesh can be transformed/scaled, etc. This was done with GLAD, GLFW, ...
5votes
1answer
773views
Strategy pattern in C++ - the Duck simulator
I'm studying design patterns from Head First Design Patterns and, in order to get confident, I plan to implement the each pattern in C++ after studying the corresponding chapter. As regards the ...
-1votes
1answer
354views
abstract base classes versus the curiously recurring template pattern [closed]
Background Apologies for "burying the lead." The questions are in the next section. In my application, the purpose of inheritance is to abstract away complicated logic in the base class template, so ...
0votes
2answers
2kviews
Get the width and height of a shape as user input
I made this program to understand inheritance better. Now that I'm at this basic level it's not really a problem but I can see this coming in the future and so I'm asking what's the best method to ...
1vote
1answer
170views
Shift register library design
I am creating a small library for controlling bars of leds and have some doubts about my design. I have 2 basic entities in the design so far: BarService (and implementation) ...
0votes
1answer
1kviews
C++ linked list inheriting from node class
I am currently in between semesters at school and am using that time to improve on my knowledge of C++ classes by making a node class and a linked list class that inherits from the node class. There ...
5votes
1answer
350views
"Detailed" exception class hierarchy
I'm designing an modular exception class hierarchy to use in various projects. I intend to inherit from std::exception in order to be maximally compatible with any ...